<script setup>
import { appScTransferCountUnsigned } from "@/services/transfer";
import topNav from "../../components/topNav.vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { nextTick, ref, watch, onMounted, onUnmounted } from "vue";
import { isOpens } from "@/utils/directive.js";

const showSelect = ref("");

if (uni.getStorageSync("selectShopType")) {
  showSelect.value = uni.getStorageSync("selectShopType");
}

onLoad((e) => {});

onShow(() => {
  // if (
  //   isOpens(["shop:stock:adjust:damage:query"]) ||
  //   isOpens(["manager:stock:adjust:damage:query"])
  // ) {

  // }
  getappScTransferCountUnsigned();
});
onUnmounted(() => {});

const UnApproveCount = ref({});
const getDamageUnApproveCount = async () => {
  let res = await damageUnApproveCount();

  UnApproveCount.value = res.data;
};

const saveFun = () => {};

const toNav = (url) => {
  uni.navigateTo({
    url: url,
  });
};

const totallObj = ref({});

const getappScTransferCountUnsigned = async () => {
  let res = await appScTransferCountUnsigned({});
  totallObj.value = res.data;
};
</script>

<template>
  <view class="bg">
    <topNav :title="'商品拆包'" @save="saveFun" rType="save"></topNav>
    <!-- <up-navbar
      bgColor="#ffffff"
      @rightClick="rightClick"
      :autoBack="true"
      :safeAreaInsetTop="true"
      :fixed="true"
      :placeholder="true"
      :leftText="'返回'"
    >
      <template #right> </template>
      <template #center>
        <text
          class="text-white"
          style="
            font-weight: 500;
            font-size: 34rpx;
            color: #000000;
            line-height: 48rpx;
            text-align: center;
          "
          >支付状态</text
        ></template
      >
    </up-navbar> -->
    <!-- v-permission="['manager:plan:query']" -->
    <view class="select" v-if="showSelect == 'admin'">
      <view class="select-item" @click="toNav('/pages/unpacking/add/index')">
        <view class="select-item-left">
          <view class="select-item-left-title"
            ><image src="@/static/transfer/6.png" mode="scaleToFill" />
            <text
              >零售商品拆包<view class="box">
                <up-badge
                  numberType="overflow"
                  :type="'error'"
                  :value="UnApproveCount.count || 0"
                ></up-badge> </view></text
          ></view>
          <view class="select-item-left-value">选择零售商品拆包</view>
        </view>
        <view class="select-item-right">
          <up-icon
            name="plus"
            color="#FF5722"
            size="46rpx"
            :bold="true"
          ></up-icon>
        </view>
      </view>
      <!-- v-permission="['manager:takeSheet:query']" -->
      <view
        class="select-item"
        v-permission="['shop:stock:unpack:create']"
        @click="toNav('/pages/unpacking/add_plist/index')"
      >
        <view class="select-item-left">
          <view class="select-item-left-title"
            ><image src="@/static/transfer/2.png" mode="scaleToFill" />
            <text class="title">拆包记录 </text>
          </view>
          <view class="select-item-left-value">查看拆包记录</view>
        </view>
      </view>
    </view>

    <view class="select" v-if="showSelect == 'shop'">
      <view
        class="select-item"
        v-permission="['shop:stock:unpack:create']"
        @click="toNav('/pages/unpacking/add/index')"
      >
        <view class="select-item-left">
          <view class="select-item-left-title"
            ><image src="@/static/transfer/5.png" mode="scaleToFill" />
            <text
              >零售商品拆包<view class="box">
                <up-badge
                  numberType="overflow"
                  :type="'error'"
                  :value="UnApproveCount.count || 0"
                ></up-badge> </view></text
          ></view>
          <view class="select-item-left-value">选择零售商品拆包</view>
        </view>
        <view class="select-item-right">
          <up-icon
            name="plus"
            color="#FF5722"
            size="46rpx"
            :bold="true"
          ></up-icon>
        </view>
      </view>

      <view
        class="select-item"
        v-permission="['shop:stock:unpack:create']"
        @click="toNav('/pages/unpacking/add_plist/index')"
      >
        <view class="select-item-left">
          <view class="select-item-left-title"
            ><image src="@/static/transfer/2.png" mode="scaleToFill" />
            <text class="title"
              >拆包记录
              <view class="box">
                <up-badge
                  numberType="overflow"
                  :type="'error'"
                  :value="UnApproveCount.count || 0"
                ></up-badge>
              </view>
            </text>
          </view>
          <view class="select-item-left-value">查看拆包记录</view>
        </view>
      </view>
    </view>
  </view>
</template>

<style lang="scss" scoped>
@import "index.scss";
</style>
